<? include ("../init.php") ?>
<? include ("../header.php") ?>
<? include ("../menu.php") ?>
<? include ("submenu.php") ?>
<?php

  $img_id = $_GET['img_id'];

  $sql = "SELECT * FROM gallery WHERE img_id = '".$img_id."'";
  $line = $db->queryUniqueObject($sql);
?>
<div id = "body">

<h1><?_l('edit')?> <?_l('showcase')?></h1>

<a href = "#" onclick = "uploadShowcaseIimg(<?php echo $img_id; ?>)" class = "add"><img src = "<?=ADMIN?>/images/icon-add.png">&nbsp;&nbsp;&nbsp;<?_l('upload-more-images')?></a>

<div class = "clear"></div>

<form method="post" action="update.php" class = "form" enctype="multipart/form-data">
  <input name="img_id" type="hidden" value="<?=$img_id?>"/>
  <input name="old_img" type="hidden" value="<?=$line->img_path?>" />
  <div class = "field"><label><?_l('detail')?></label><input type = "text" name = "detail" class = "input size1" value = "<?=$line->img_title?>" ></div>
  <div class = "field"><label><?_l('image')?></label><input type = "file" name = "gallery_img" class = "input size1" ></div>
  <?php
    if($line->img_path!='' && file_exists('../../images/header_slide/'.$line->img_path)){
      echo '<div class = "field"><label>&nbsp;</label><img src="../../images/header_slide/'.$line->img_path.'" /></div>';
    }
  ?>
  <br />
  <div class = "field"><label></label>
    <input type="submit" name="save" value = "<?_l('update')?>" class = "btn" />
    <input onclick = "javascript:history.back(1)" type = "button" value="<?_l('cancel')?>" class = "btn" />
  </div>
  
  <div class = "clear"></div>
</form>

</div>


<style>
  .form label {
    width:80px;
  }
</style>
<script type="text/javascript" src="../js/jquery.dragsort-0.3.10.js"></script>
    <script type="text/javascript">
	$(document).ready(function(){
	    $('.deleteImg').click(function(){
		
		var imgEle = $(this);
		var id = imgEle.attr('id');
		
		if(confirm('Sure?'))
		{
		    imgEle.parents("li").find('.delete_indicator').css('display','inline');
		    $.post('del.php','imgId='+id,function(data){
			imgEle.parents("li").remove();
		    });
		}
	    });
	    
	    $("#list1").dragsort({ dragSelector: "div", dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "<li class='placeHolder'><div></div></li>" });
	});
	
	function saveOrder() {
	    var serialStr = "";
	    $("#list1 li span").each(function(i, elm) {
		serialStr += (i > 0 ? "|" : "") + $(elm).children("p").html();
	    });
	    
	    $("input[name=list1SortOrder]").val(serialStr);
	};
    </script>
<? include ("../footer.php") ?>